//
//  VefityTool.m
//  zijiaosuo
//
//  Created by FXGuo on 16/5/22.
//  Copyright © 2016年 guoguo. All rights reserved.
//

#import "VefityTool.h"

@implementation VefityTool

+ (BOOL)isValidTellNumber:(NSString *)number
{
    NSString *pattern = @"^1+[34578]+\\d{9}";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
    BOOL isValid = [pred evaluateWithObject:number];
    return isValid;
}

+ (BOOL)isPureInt:(NSString *)string
{
    NSScanner* scan = [NSScanner scannerWithString:string];
    int val;
    return[scan scanInt:&val] && [scan isAtEnd];
}

+ (BOOL)isPureFloat:(NSString *)string
{
    NSScanner* scan = [NSScanner scannerWithString:string];
    float val;
    return[scan scanFloat:&val] && [scan isAtEnd];
}
+ (BOOL)isValidNumber:(NSString *)str
{
    if(![self isPureInt:str]&&![self isPureFloat:str]){
        return NO;
    }
    return YES;
}

//+ (BOOL)isValidNumber:(NSString *)str
//{
//    NSString *inputString = [str stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
//    NSLog(@"%@",inputString);
//    if(inputString.length < 1) {
//        return YES;
//    }
//    return NO;
//}

@end
